﻿using System.Net.WebSockets;

namespace DongFangGuoKai.WMSPlatform.WebApi.Collection
{
    public class WebSocketCollection
    {
        private static List<WebSocketClient> _clients = new List<WebSocketClient>();

        public static void AddSocketClient(WebSocketClient client)
        {
            _clients.Add(client);
        }

        public static List<WebSocketClient> GetAllSocketClients()
        {
            return _clients;
        }
        public static void RemoveSocket(WebSocketClient webSocketClient)
        {
            _clients.Remove(webSocketClient);
        }
        public static WebSocketClient Get(string clientId)
        {
            return _clients.FirstOrDefault(t => t.Id == clientId);
        }

        public static List<WebSocketClient> GetRoomClients(string roomId)
        {
            return _clients.Where(t => t.RoomNo == roomId).ToList();
        }



    }
    public class WebSocketClient
    {
        public string? Id { get; set; }
        public string? RoomNo { get; set; }
        public WebSocket? WebSocket { get; set; }
    }

    public class WebSocketClientModel
    {
        public string? SendClientId { get; set; }
        public string? RoomNo { get; set; }
        public string? Action { get; set; }
    }

}
